import type { Recordable } from '@vben/types';

import { requestClient } from '#/api/request';

export namespace SystemTenantPackageApi {
  export interface SystemTenantPackage {
    [key: string]: any;
    id: string;
    name: string;
  }
}

/**
 * 获取租户列表数据
 */
const getTenantPackageList = (params: Recordable<any>): Promise<Array<SystemTenantPackageApi.SystemTenantPackage>> => {
  return requestClient.get('/system/tenant_package/', { params });
};

/**
 * 创建租户
 * @param data 租户数据
 */
const createTenantPackage = (
  data: Omit<SystemTenantPackageApi.SystemTenantPackage, 'id'>,
): Promise<SystemTenantPackageApi.SystemTenantPackage> => {
  return requestClient.post('/system/tenant_package/', data);
};

/**
 * 更新租户
 *
 * @param id 租户 ID
 * @param data 租户数据
 */
const updateTenantPackage = (
  id: string,
  data: Omit<SystemTenantPackageApi.SystemTenantPackage, 'id'>,
): Promise<SystemTenantPackageApi.SystemTenantPackage> => {
  return requestClient.put(`/system/tenant_package/${id}/`, data);
};
/**
 * 更新租户
 *
 * @param id 租户 ID
 * @param data 租户数据
 */
const patchTenantPackage = (
  id: string,
  data: Omit<SystemTenantPackageApi.SystemTenantPackage, 'id'>,
): Promise<SystemTenantPackageApi.SystemTenantPackage> => {
  return requestClient.patch(`/system/tenant_package/${id}/`, data);
};

/**
 * 删除租户
 * @param id 租户 ID
 */
const deleteTenantPackage = (id: string): Promise<any> => {
  return requestClient.delete(`/system/tenant_package/${id}/`);
};

export {
  createTenantPackage,
  deleteTenantPackage,
  getTenantPackageList,
  patchTenantPackage,
  updateTenantPackage,
};
